﻿

@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>LeaveAdd</title>

    <link href="~/layui-v2.6.8/layui/css/layui.css" rel="stylesheet" />

    <script src="~/layui-v2.6.8/layui/layui.js"></script>
    <script src="~/lib/jquery/dist/jquery.js"></script>
</head>
<body>

    <form class="layui-form" action="" id="UptForm">

        <div class="layui-form-item">
            <label class="layui-form-label">请假编号</label>
            <div class="layui-input-block">
                <input type="text" name="lnum" lay-verify="lnum" autocomplete="off" placeholder="请输入标题" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">请假类型</label>
            <div class="layui-input-block">
                <input type="text" name="ltype" id="ltype" lay-verify="title" autocomplete="off" placeholder="请输入标题" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">开始时间</label>
                <div class="layui-input-block">
                    <input type="text" name="lbegintime" id="lbegintime" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">结束时间</label>
                <div class="layui-input-block">
                    <input type="text" name="lovertime" id="lovertime" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>


        <div class="layui-form-item" pane="">
            <label class="layui-form-label">状态</label>
            <div class="layui-input-block">
                <input type="radio" name="lshi" value="1" title="1" checked="">
                <input type="radio" name="lshi" value="0" title="0">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">请假天数</label>
            <div class="layui-input-block">
                <input type="text" name="ldays" lay-verify="ldays" autocomplete="off" placeholder="请输入标题" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">请假理由</label>
            <div class="layui-input-block">
                <input type="text" name="linfo" lay-verify="linfo" autocomplete="off" placeholder="请输入标题" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">立即添加</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>



    <script src="//res.layui.com/layui/dist/layui.js" charset="utf-8"></script>
    <!-- 注意：如果你直接复制所有代码到本地，上述 JS 路径需要改成你本地的 -->
    <script>





        layui.use(['form', 'layedit', 'laydate'], function () {
            var form = layui.form
                , layer = layui.layer
                , layedit = layui.layedit
                , laydate = layui.laydate;

            //日期
            laydate.render({
                elem: '#Lbegintime',
                elem: '#Lovertime'
            });
            laydate.render({
                elem: '#Lbegintime',
                elem: '#Lovertime'
            });

            //创建一个编辑器
            var editIndex = layedit.build('LAY_demo_editor');



            //监听指定开关
            form.on('switch(switchTest)', function (data) {
                layer.msg('开关checked：' + (this.checked ? 'true' : 'false'), {
                    offset: '6px'
                });
                layer.tips('温馨提示：请注意开关状态的文字可以随意定义，而不仅仅是ON|OFF', data.othis)
            });

            //监听提交
            form.on('submit(demo1)', function (data) {
                $.ajax({
                    url: 'http://localhost:36862/api/JuSe/LeaveAdd',
                    data: $("#UptForm").serialize(),
                    type: 'post',
                    success: function (d) {
                        if (d > 0) {
                            layer.msg('修改成功', { time: 2000, icon: 1 }, function () {
                                parent.location.href = '/ZiTi/ZiTiShow';
                            })
                        }
                        else {
                            layer.msg('修改失败', { time: 2000, icon: 2 }, function () {
                                parent.location.href = '/ZiTi/LeaveAdd';
                            })
                        }

                    }
                })
                return false;
            });

            //表单赋值
            layui.$('#LAY-component-form-setval').on('click', function () {
                form.val('example', {
                    "username": "贤心" // "name": "value"
                    , "password": "123456"
                    , "interest": 1
                    , "like[write]": true //复选框选中状态
                    , "close": true //开关状态
                    , "sex": "女"
                    , "desc": "我爱 layui"
                });
            });

            //表单取值
            layui.$('#LAY-component-form-getval').on('click', function () {
                var data = form.val('example');
                alert(JSON.stringify(data));
            });

        });
    </script>
</body>
</html>

